package org.ws.edu.task1.pool;

import junit.framework.Assert;

import org.junit.BeforeClass;
import org.junit.Test;
import org.ws.edu.task1.IConsoleHandler;

public class TestCalcNum {
    private static IConsoleHandler handler;

    @BeforeClass
    public static void init() {
        handler = new CalcNumMain();
    }

    @Test
    public void testNormal() {
        handler.handle("((2+3*2)+((2/4+5)- 2)*3 )*2");
    }

    @Test
    public void testIncorrectInput() {
        handler.handle("fdsfsdfdsfdsf");
    }

    @Test
    public void testHardIncorrectInput() {
        handler.handle("x+y");
    }

    @Test
    public void testFactorialException() {
        String result = handler.handle("(6-8)!");
    }

    @Test
    public void testSum() {
        String result = handler.handle("2+2");
        Assert.assertEquals("= 4.0", result);
    }

    @Test
    public void testSubstract() {
        String result = handler.handle("2-12");
        Assert.assertEquals("= -10.0", result);
    }

    @Test
    public void testMultiply() {
        String result = handler.handle("2*12");
        Assert.assertEquals("= 24.0", result);
    }

    @Test
    public void testDivide() {
        String result = handler.handle("24/6");
        Assert.assertEquals("= 4.0", result);
    }

    @Test
    public void testPow() {
        String result = handler.handle("4^2");
        Assert.assertEquals("= 16.0", result);
    }

    @Test
    public void testSqrt() {
        String result = handler.handle("4|2)");
        Assert.assertEquals("= 2.0", result);
    }

    @Test
    public void testFactorial() {
        String result = handler.handle("3!");
        Assert.assertEquals("= 6.0", result);
    }

    @Test
    public void testExpression() {
        String result = handler.handle("(-25/-5*-5");
        Assert.assertEquals("= -25.0", result);
    }

    @Test
    public void testCalcNum() {
    }

}
